<script src="${request.contextPath}/assets/js/jquery3.6.0.js"></script>
<script src="${request.contextPath}/assets/js/jquery-validate/jquery.validate.js"></script>
<script src="${request.contextPath}/assets/js/jquery-validate/messages_zh.js"></script>

<form action="${request.contextPath}/province/update" method="post" id="provinceForm">
    <input type="hidden" name="id" value="${province.id}">
    省名： <input type="text" name="name" value="${province.name}"> <br>
    大区：<select name="area">
        <option value="华北" <#if province.area="华北"> selected</#if> >华北</option>
        <option value="华东" <#if province.area="华东"> selected</#if> >华东</option>
        <option value="华南" <#if province.area="华南"> selected</#if> >华南</option>
        <option value="华中" <#if province.area="华中"> selected</#if> >华中</option>
        <option value="西北" <#if province.area="西北"> selected</#if> >西北</option>
        <option value="西南" <#if province.area="西南"> selected</#if> >西南</option>
        <option value="港奥台" <#if province.area="港奥台"> selected</#if> >港奥台</option>
        <option value="东北" <#if province.area="东北"> selected</#if> >东北</option>
    </select> <br>
    优先级：<input type="text" name="priority" value="${province.priority}"> <br>
    状态：<input type="radio" name="status" value="1" <#if province.status==1>checked</#if> > 可用
    <input type="radio" name="status" value="2" <#if province.status==2>checked</#if>> 禁用 <br>
    <input type="submit" value="提交">
</form>

<script>
    $(function () {
        $("#provinceForm").validate({
            rules: {
                name: {
                    required: true,
                },
                area: {
                    required: true
                },
                priority: {
                    required: true,
                    digits: true,
                    range: [0, 255]
                },
                status: {
                    required: true,
                    range: [1, 2]
                }
            }
            , messages: {
                name: "省名不能为空",
                area: "大区不能为空",
                priority: "优先级不能为空且得是[0,256]之间的整数",
                status:"状态值必须是1或者2"
            }
        });
    })
</script>